#include<bits/stdc++.h>
using namespace std;
#define ERROR 0
#define OK 1
typedef int Status;
typedef struct LNode{
	int data;
	LNode *next;	
}LNode, *LinkList;
Status Init(LinkList &L)
{
	L = new LNode;
	if(!L) return ERROR;
	L->next = L;
	return OK;
}
Status Create(LinkList &L, int n)
{
	LNode *t = L;
	for(int i = 0; i < n; i ++)
	{
		LNode *p = new LNode;
		cin >> p->data;
		t->next = p;
		p->next = L;
		t = p;
	}
}
void Del_All(LinkList &L)
{
	/********************Begin*****************/
    while(L->next != L)
	{
		LNode *min_pre = L;
		LNode *cur_pre = L;
		LNode *cur = L->next;	
		int min = cur->data;
		
		while(cur != L)
		{
			if(cur->data < min)
			{
				min = cur->data; 
				min_pre = cur_pre;
			}
			cur_pre = cur;
			cur = cur->next; 
		}
		
		LNode *q = min_pre->next;
		min_pre->next = q->next;
		cout << q->data << " ";
	}
		cout << endl;
    /*********************End*******************/
}
void Show(LinkList L)
{
	LNode *p = L->next;
	while(p != L)
	{
		cout << p->data << ' ';
		p = p->next;
	}
	cout << endl;
}
int main()
{
	LinkList L;
	Init(L);
	
	int n;
	cin >> n;
	Create(L, n);
 
	Del_All(L);
	
	return 0; 
}